#include "stdafx.h"
#include "bmp.h"

bool bmp_create(uint_8 * buffer, uint_32 length, image_data_t * img)
{
	bmp_image_data_t bmp;
	if(bmp_create_ex(buffer, length, &bmp))
	{
		*img = bmp.img_data;
		return true;
	}
	else
		return false;
}
bool bmp_create_ex(uint_8 * buffer, uint_32 length, bmp_image_data_t * bmp)
{
	bmp_simple_header_t * header = (bmp_simple_header_t *)buffer;
	if(header->type != BMP_HEADER_ID)
		return false;

	switch(header->info_size)
	{
	case sizeof(bmp_info_windows_t):
	case sizeof(bmp_info_windows_t) + sizeof(color_mask_abgr_t):
		return bmp_create_windows(buffer, length, bmp);
	case sizeof(bmp_info_os2_t):
		return bmp_create_os2(buffer, length, bmp);
	default:
		break;
	}
	return false;
}
